package com.xpq.petserver.config;

import com.xpq.petserver.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * jwt拦截器
 */
@Configuration
public class JwtInterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/**") // 拦截全部
                .excludePathPatterns("/webjars/**","/v3/**","/doc.html/**") // 放行api文档
                .excludePathPatterns("/","/index.html","/init.css","/favicon.ico", "/js/**", "/css/**", "/json/**", "/img/**") // 放行排除静态资源
                .excludePathPatterns("/user/login","/user/register") // 排除登录注册接口
                .excludePathPatterns("/bailmentData/searchBailmentData","/bailmentData/getBailmentDetail") // 放行宠物信息接口
                .excludePathPatterns("/file/**"); // 放行图片头像文件访问
    }
}
